package com.longxi.tianjintianbao.ui.adapter.multitype.approval;

import android.support.annotation.NonNull;
import android.support.v7.widget.RecyclerView;
import android.view.LayoutInflater;
import android.view.View;
import android.view.ViewGroup;
import android.widget.LinearLayout;
import android.widget.TextView;

import com.longxi.tianjintianbao.R;
import com.longxi.tianjintianbao.listener.AdapterListener;
import com.longxi.tianjintianbao.model.approval.Approval;
import com.longxi.tianjintianbao.model.approval.ApprovalContent;

import me.drakeet.multitype.ItemViewBinder;

/**
 * Created by cxw on 2018/2/20.
 */
public class ApprovalContentViewBinder extends ItemViewBinder<ApprovalContent, ApprovalContentViewBinder.ViewHolder> {

    AdapterListener listener;

    public ApprovalContentViewBinder(AdapterListener listener) {
        this.listener = listener;
    }

    @NonNull
    @Override
    protected ViewHolder onCreateViewHolder(@NonNull LayoutInflater inflater, @NonNull ViewGroup parent) {
        View root = inflater.inflate(R.layout.item_approval_content, parent, false);
        return new ViewHolder(root);
    }

    @Override
    protected void onBindViewHolder(@NonNull ViewHolder holder, @NonNull ApprovalContent approvalContent) {
        holder.tvContentName.setText("合同名称:" + approvalContent.getName());
        holder.tvContentNum.setText("合同编号:" + approvalContent.getCode());
        holder.tvContentPrice.setText("合同总额:" +"￥"+ approvalContent.getAmount() + "\n客户信息:" + approvalContent.getCust() + "\n签约日期:" + approvalContent.getSigningdate());
        holder.tvContentSign.setVisibility(View.GONE);
    }

    public class ViewHolder extends RecyclerView.ViewHolder {
        TextView tvContentName;
        TextView tvContentNum;
        TextView tvContentPrice;
        TextView tvContentSign;
        ViewHolder(View itemView) {
            super(itemView);
            tvContentName = itemView.findViewById(R.id.tvContentName);
            tvContentNum = itemView.findViewById(R.id.tvContentNum);
            tvContentPrice = itemView.findViewById(R.id.tvContentPrice);
            tvContentSign = itemView.findViewById(R.id.tvContentSign);
        }
    }
}
